/**
 * @Author: 健聪
 * @Description: 数据类型：字符串
 * @Date: 2024/01/09
 */
void main () {
  String str1 = 'Hello';
  String str2 = '''Hello
                 Dart ''';
  print(str1);
  print(str2);

  // String str3 = 'Hello \n Dart';
  String str3 = r'Hello \n Dart';   // 换行
  print(str3);

  String str4 = "This is my favorite language";
  print(str4 + "New");  // 加入新内容
  print(str4 * 5);      // 重复出现5次
  print(str3 == str4);
  print(str4[0]);

  int a = 1;
  int b = 2;
  print("a + b = ${ a + b }"); //  插值表达式
  print("a = $a");

  print(str4.length);   // 长度
  print(str4.isEmpty);  // 是否为空

  //  截取字符串
  print(str4.contains("This"));
  print(str4.substring(0, 3));
  print(str4.startsWith("a"));
  print(str4.endsWith("ge"));
  print(str4.indexOf("is"));
  print(str4.lastIndexOf("g"));
  print(str4.toLowerCase());
  print(str4.toUpperCase());
  print(str4.trim());
  print(str4.trimLeft());
  print(str4.trimRight());


  var list = str4.split("   ");
  print(list);

  String text ="one, two, three, four";
  String delimiter = ",";
  print(text.split(delimiter));
  
}